package application
{
	import application.controller.SetupModelCommand;
	import application.controller.SetupViewCommand;
	import application.controller.StartupCommand;
	import application.controller.SubmitPostCommand;
	
	import org.puremvc.interfaces.IFacade;
	import org.puremvc.patterns.facade.Facade;
	
	public class ApplicationFacade extends Facade implements IFacade
	{
		// Notification name constants.
		public static const STARTUP:String = "startup";
		
		public static const CONFIG_INIT:String = "config_init";
		
		public static const SERVER_REQUEST:String = "server_request";
		public static const SERVER_RESULT:String = "server_result";
		public static const SERVER_FAULT:String = "server_fault";
		
		public static const MODEL_INIT:String = "model_init";
		
		public static const VIEW_SETUP:String = "view_setup";
		public static const VIEW_INIT:String = "view_init";
		
		public static const SUBMIT_POST:String = "submit_post";
		
		public static const MODEL_CHANGED:String = "model_changed";
		
		public static const PAGE_SELECTED:String = "page_selected";
		
		/**
		 * Singleton ApplicationFacade Factory Method.
		 */
		public static function getInstance():ApplicationFacade
		{
			if ( instance == null ) instance = new ApplicationFacade();
			return instance as ApplicationFacade;
		}
		
		/**
		 * Register Commands with the Controller.
		 */
		override protected function initializeController():void
		{
			super.initializeController();
			
			registerCommand( ApplicationFacade.STARTUP, StartupCommand );
			registerCommand( ApplicationFacade.CONFIG_INIT, SetupModelCommand );
			registerCommand( ApplicationFacade.VIEW_SETUP, SetupViewCommand );
			registerCommand( ApplicationFacade.SUBMIT_POST, SubmitPostCommand );
		}
	}
}